package com.lenovo.smarttraffic.ui.activity;

import android.graphics.Rect;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.lenovo.smarttraffic.R;
import com.lenovo.smarttraffic.bean.LitepalBean.DBUserCollectBean;
import com.lenovo.smarttraffic.ui.adapter.MyUserCollectRecyclerAdapter;
import com.lenovo.smarttraffic.view.SlideRecyclerView;

import org.litepal.LitePal;

import java.util.List;

/**
 * Created by Caleb.F
 * on 2020-03-17
 * at 21:47
 */
public class UserCollectActivity extends BaseActivity {
    private static final String TAG = "UserCollectActivity";
    private SlideRecyclerView mUserInfoRecyclerView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initView();
    }

    private void initView() {
        initToolBar("用户收藏");
        mUserInfoRecyclerView = findViewById(R.id.userInfoRecyclerView);
        initRecylerView();
    }

    /**
     *
     */
    private void initRecylerView() {
        mUserInfoRecyclerView.setLayoutManager(new LinearLayoutManager(this,
                LinearLayoutManager.VERTICAL, false));
        List<DBUserCollectBean> all = LitePal.findAll(DBUserCollectBean.class);
        MyUserCollectRecyclerAdapter UserCollectRecyclerAdapter = new MyUserCollectRecyclerAdapter(this, all);
        mUserInfoRecyclerView.setAdapter(UserCollectRecyclerAdapter);
        mUserInfoRecyclerView.addItemDecoration(new RecyclerView.ItemDecoration() {
            @Override
            public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
                outRect.top = 20;
            }
        });
    }


    @Override
    protected int getLayout() {
        return R.layout.activity_user_manger;
    }


}
